import * as Vector from "../common/vector";

export type Chess = "White" | "Black";
export type Cell = "Empty" | Chess;


export interface OnTurn {
    type: "OnTurn"
    readonly chess: Chess
}

export type Winner = "Draw" | Chess;
export interface End {
    type: "End"
    readonly chess: Chess
    readonly winner: Winner
}

export interface Skip {
    type: "Skip"
    readonly chess: Chess
}

export type Turn = OnTurn | End | Skip;

export interface Movement {
    type: "Movement"
    readonly point: Vector.Vector
    readonly chess: Chess
}

export interface ConfirmSkip {
    type: "ConfirmSkip"
    readonly chess: Chess
}

export type TurnAction = Movement | ConfirmSkip;

export interface Game {
    getCurrentBoard(): Cell[][]
    getCurrentTurn(): Turn
    applyAction(action: TurnAction): Game | string
    getHistory(): TurnAction[]
}

export const RowCount = 8;
export const ColumnCount = 8;

export function InBoard(v: Vector.Vector): boolean {
    return v.x >= 0 &&
        v.x < RowCount &&
        v.y >= 0 &&
        v.y < ColumnCount
}